visualizer
/
vendor
/
phpoffice
/
phpexcel
/
Documentation
/
Examples
/
Reading WorkBook Data
/
exampleWorkBookReader03.php
exampleWorkBookReader03.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 3.1.1, at vendor/phpoffice/phpexcel/Documentation/Examples/Reading WorkBook Data/exampleWorkBookReader03.php
| 1 | <?php |
| 2 | |
| 3 | error_reporting(E_ALL); |
| 4 | set_time_limit(0); |
| 5 | |
| 6 | date_default_timezone_set('Europe/London'); |
| 7 | |
| 8 | ?> |
| 9 | <html> |
| 10 | <head> |
| 11 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| 12 | |
| 13 | <title>PHPExcel Reading WorkBook Data Example #03</title> |
| 14 | |
| 15 | </head> |
| 16 | <body> |
| 17 | |
| 18 | <h1>PHPExcel Reading WorkBook Data Example #03</h1> |
| 19 | <h2>Read Custom Property Values for a WorkBook</h2> |
| 20 | <?php |
| 21 | |
| 22 | /** Include path **/ |
| 23 | set_include_path(get_include_path() . PATH_SEPARATOR . '../../../Classes/'); |
| 24 | |
| 25 | /** PHPExcel_IOFactory */ |
| 26 | include 'PHPExcel/IOFactory.php'; |
| 27 | |
| 28 | |
| 29 | $inputFileType = 'Excel2007'; |
| 30 | $inputFileName = './sampleData/example1.xlsx'; |
| 31 | |
| 32 | /** Create a new Reader of the type defined in $inputFileType **/ |
| 33 | $objReader = PHPExcel_IOFactory::createReader($inputFileType); |
| 34 | /** Load $inputFileName to a PHPExcel Object **/ |
| 35 | $objPHPExcel = $objReader->load($inputFileName); |
| 36 | |
| 37 | |
| 38 | echo '<hr />'; |
| 39 | |
| 40 | /** Read an array list of any custom properties for this document **/ |
| 41 | $customPropertyList = $objPHPExcel->getProperties()->getCustomProperties(); |
| 42 | |
| 43 | echo '<b>Custom Properties: </b><br />'; |
| 44 | /** Loop through the list of custom properties **/ |
| 45 | foreach($customPropertyList as $customPropertyName) { |
| 46 | echo '<b>',$customPropertyName,': </b>'; |
| 47 | /** Retrieve the property value **/ |
| 48 | $propertyValue = $objPHPExcel->getProperties()->getCustomPropertyValue($customPropertyName); |
| 49 | /** Retrieve the property type **/ |
| 50 | $propertyType = $objPHPExcel->getProperties()->getCustomPropertyType($customPropertyName); |
| 51 | |
| 52 | /** Manipulate properties as appropriate for display purposes **/ |
| 53 | switch($propertyType) { |
| 54 | case 'i' : // integer |
| 55 | $propertyType = 'integer number'; |
| 56 | break; |
| 57 | case 'f' : // float |
| 58 | $propertyType = 'floating point number'; |
| 59 | break; |
| 60 | case 's' : // string |
| 61 | $propertyType = 'string'; |
| 62 | break; |
| 63 | case 'd' : // date |
| 64 | $propertyValue = date('l, d<\s\up>S</\s\up> F Y g:i A',$propertyValue); |
| 65 | $propertyType = 'date'; |
| 66 | break; |
| 67 | case 'b' : // boolean |
| 68 | $propertyValue = ($propertyValue) ? 'TRUE' : 'FALSE'; |
| 69 | $propertyType = 'boolean'; |
| 70 | break; |
| 71 | } |
| 72 | |
| 73 | echo $propertyValue,' (',$propertyType,')<br />'; |
| 74 | } |
| 75 | |
| 76 | |
| 77 | |
| 78 | ?> |
| 79 | <body> |
| 80 | </html> |
| 81 |